<template>
  <view class="container-refundDetail">
    <header @click="$goPath(1)">
      <image src='/static/images/right-white.png' mode='aspectFit|aspectFill|widthFix' alt="" />
      <view>退款详情</view>
    </header>

    <section>
      <view class="sect-box">
        <view class='sect-title'>
          <view>
            <view class='title-icon'>
              <view> <u-icon name="clock" /> </view>
              <text>申请退款</text>
            </view>
            申请退款
          </view>
          <view>您已提交退款申请，请等待客服处理</view>
        </view>

        <view class='sect-sum'>
          <view>退款合计</view>
          <view>
            <view>￥<text>{{ orderDetail.totalPrice || '0.00' }}</text></view>
            <view>按实付金额计算，原路退回</view>
          </view>
        </view>

        <view class='sect-steps'>
          <view class='title'>退款流程</view>
          <view class='process-steps'>

            <u-steps current="1" activeColor="#32B499">
              <u-steps-item title="提交申请"></u-steps-item>
              <u-steps-item title="审核中"></u-steps-item>
              <u-steps-item title="退款成功"></u-steps-item>
            </u-steps>

          </view>
          <view class='process-timer'>{{ orderDetail.refundApplyTime }}</view>
        </view>

        <view class="sect-img">
          <image
            src="https://youpindou.com:8083/doudougou/image/showImg?imgUrl=/home/ddg_test/images/faccacac-a9eb-4145-8754-e27e29c1120a.png"
            alt="" mode='widthFix' />
        </view>

        <view class="sect-goodsList">
          <view class='title'>退款流程</view>

          <view class='goods-item' v-for="(item, index) in orderDetail.orderDetailList" :key="index">
            <view class='goods-item-img'>
              <img :src="item.thumbnailUrl" mode='aspectFit|aspectFill|widthFix' alt="" />
            </view>
            <view class='goods-item-content'>
              <view class='goods-item-name'>{{ item.productName }}</view>

              <view class="goods-item-tag" v-if="item.limitation == 1">
                {{ item.limitationSell == 0 ? `限购${item.limitationCount}件` :
                  `限购${item.limitationCount}件，第${item.limitationCount + 1}件恢复原价` }}
              </view>

              <view class='goods-item-price' v-if="!item.limitation">
                <view>原价￥<text>{{ item.showPrice }}</text>元</view>
                <view>共{{ item.count }}件</view>
              </view>

              <view class='goods-item-price' v-else-if="item.limitationBuyCount == 0">
                <view>限购价￥{{ item.limitationPrice }}元</view>
                <view>共{{ item.count - item.limitationBuyCount }}件</view>
              </view>

              <view class='goods-price' v-else>
                <view class='goods-item-price' v-if="item.count - item.limitationBuyCount > 0">
                  <view>限购价￥{{ item.limitationPrice }}元</view>
                  <view>共{{ item.count - item.limitationBuyCount }}件</view>
                </view>

                <view class='goods-item-price'>
                  <view>原价￥{{ item.showPrice }}元</view>
                  <view>共{{ item.limitationBuyCount }}件</view>
                </view>
              </view>

            </view>
          </view>
        </view>

        <view class="sect-cancelRefund">
          <view @click="onCancelRefund()">取消退款</view>
        </view>
      </view>
    </section>
  </view>
</template>

<script>

export default {
  data() {
    return {
      orderDetail: {},
    }
  },
  onLoad(options) {
    this.orderDetail = JSON.parse(decodeURIComponent(options.orderDetail));
  },
  methods: {

    onCancelRefund() {
      const param = { orderId: this.orderDetail.orderId }
      this.$request.orderCancelRefund(param).then(res => {
        if (res.code == 200 && res.isSuccess) {
          uni.showToast({ title: '取消退款成功', icon: 'success' });
          this.$goPath(1);
        } else {
          this.$toast('取消退款失败，请稍后再试!')
        }
      });
    },
  },


}
</script>
<style scoped>
.container-refundDetail {
  width: 100%;
  height: 100vh;
  font-size: 14px;
  font-family: 'PingFang SC-Medium';
  background-color: #FED14E;
}

.container-refundDetail header {
  width: 100%;
  padding: 60px 12px 30px;
  border-radius: 0 0 20px 20px;
  box-sizing: border-box;
  color: #fff;
  background-color: #32B499;
  background-image: url('https://youpindou.com/miniProgram/image/showImg?imgUrl=/home/ypd/images/homeTopIcon.png');
  background-size: 100% auto;
  background-repeat: no-repeat;
  font-size: 18px;
  font-family: 'PingFang SC-Bold';
  display: flex;
  align-items: center;
  position: relative;
  top: 0;
  left: 0;
}

.container-refundDetail header>image {
  width: 8px;
  height: 16px;
  display: block;
  margin-right: 3px;
}

.container-refundDetail>section {
  height: 90%;
  position: relative;
  top: -25px;
  padding: 0 12px;
  box-sizing: border-box;
}

.sect-box {
  width: 100%;
  height: 100%;
  background-color: #fff;
  border-radius: 20px 20px 0 0;
  padding: 12px;
  box-sizing: border-box;
}

.container-refundDetail .sect-title {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(241, 241, 241, 0.8);
  box-sizing: border-box;
}

.container-refundDetail .sect-title>view:first-child {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  font-size: 16px;
}

.container-refundDetail .title-icon {
  font-size: 14px;
  border: 1px solid #DBDFE4;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 3px;
  box-sizing: border-box;
  margin-right: 10px;
}

.container-refundDetail .title-icon>view {
  width: 20px;
  height: 20px;
  background: #DBDFE4;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 10px;
}

.container-refundDetail .sect-title>view:last-child {
  font-size: 14px;
  color: #999999;
}

.container-refundDetail .sect-sum {
  padding-top: 12px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-sizing: border-box;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(241, 241, 241, 0.8);
  box-sizing: border-box;
}

.container-refundDetail .sect-sum>view:first-child {
  font-size: 16px;
}

.container-refundDetail .sect-sum>view:last-child {
  text-align: right;
  font-size: 14px;
  color: #666;
}

.container-refundDetail .sect-sum>view:last-child>view:first-child {
  font-size: 14px;
  color: #EA5F5F;
}

.container-refundDetail .sect-sum>view:last-child>view:first-child text {
  font-family: 'DIN-Bold';
  font-size: 20px;
}


.container-refundDetail .sect-steps {
  padding: 12px 0;
  box-sizing: border-box;
  margin-bottom: 12px;
}

.title {
  font-size: 16px;
  margin-bottom: 5px;
}

.container-refundDetail .sect-steps>.process-timer {
  color: #999999;
  font-family: 'DIN-Regular';
}

.sect-img {
  margin-bottom: 12px;
}

.sect-goodsList {

  border-bottom: 1px solid rgba(241, 241, 241, 0.8);
}

.goods-item {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 12px;
}

.goods-item .goods-item-img {
  width: 70px;
  height: 70px;
}

.goods-item-img img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 4px;
}

.goods-item .goods-item-content {
  flex: 1;
  height: 70px;
  padding-left: 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.goods-item .goods-item-name {
  font-size: 16px;
  font-family: 'PingFang SC-Bold';
  font-weight: bold;
  color: #333333;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  /* 设置超过为省略号的行数 */
  overflow: hidden;
}

.goods-item-tag {
  font-size: 10px;
  width: fit-content;
  padding: 2px 5px;
  background: #FDF3F3;
  color: #EA5F5F;
  font-family: 'PingFang SC-Medium';
  border-radius: 4px;
  box-sizing: border-box;
}

.goods-item .goods-price {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.goods-item-price {
  display: flex;
  align-items: flex-end;
  margin-right: 12px;
}

.goods-item .goods-item-price>view:first-child>text {
  font-size: 16px;
  color: #333333;
  font-family: 'DIN-Bold';
}

.goods-item .goods-item-price>view:last-child {
  margin-left: 5px;
  color: #999999;
}

.sect-cancelRefund {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.sect-cancelRefund>view {
  width: 110px;
  height: 35px;
  background: #32B499;
  border-radius: 20px;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>